<template>
  <el-container>
    <el-main>
      <template>
        <el-table :data="taskPaths" style="width: 100%">
          <el-table-column prop="tstkno" label="任务号" width="180" />
          <el-table-column prop="procno" label="流程号" width="180" />
          <el-table-column prop="nodesn" label="节点" width="80" />
          <el-table-column prop="nodename" label="节点名称" width="220" />
          <el-table-column prop="senddate" label="提交时间" />
        </el-table>
      </template>
    </el-main>
    <el-footer>
      <div class="block">
        <el-pagination
          :current-page="page.current"
          :page-sizes="[5,10, 20, 50, 100]"
          :page-size="page.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-footer>
  </el-container>
</template>
<script>
import request from '@/utils/request'
export default {
  name: 'TaskPathList',
  props: { task: Object },
  data: function() {
    return {
      conditions: [
        {
          field: 'tstkno',
          type: 'STRING',
          value: this.task.tstkno,
          symbol: 'EQ'
        }
      ],
      baseUrl: process.env.VUE_APP_BASE_API,
      selected: [],
      selectObjs: [],
      page: {
        current: 1,
        size: 5,
        total: 0
      },
      taskPaths: []
    }
  },
  computed: {
    key_logic: function() {
      const { logic = {}} = this.$store.state.directory.directoryItem
      return logic
    }
  },
  created() {
    this.directoryUpdate()
    this.query()
  },
  methods: {
  // 字典更新
    directoryUpdate: function() {
      this.$store.commit('directory/setDirectory', 'logic')
    },
    // 搜索
    search: function() {
      this.page.current = 1
      this.query()
    },
    // 查询
    query: function() {
      this.$progress.start()
      this.page.conditions = this.conditions
      request({
        url: '/task/taskPath/query',
        method: 'post',
        data: this.page
      }).then(res => {
        this.$progress.done()
        if (res.result) {
          this.page.total = res.data.total
          this.taskPaths = res.data.data
        } else {
          this.$message.error(res.msg)
        }
      }).catch(() => { this.$progress.done() })
    },
    // 每页显示数目发生变化时
    handleSizeChange: function(val) {
      this.page.size = val
      this.page.current = 1
      this.query()
    },
    // 当前页发生变化时
    handleCurrentChange: function(val) {
      this.page.current = val
      this.query()
    }
  }
}
</script>
